import torch
from torch.autograd import Variable

#定义
x = Variable(torch.ones(2,2),requires_grad=True)
print(x.grad_fn)
#计算,且requires_grad=True
m = x + 2
print(m.grad_fn)
print(m.grad_fn(x))
